#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
using namespace std;

#define READ_FILE

int g_desRow;
int g_desCol;
struct KnightPos
{
	int row;
	int col;
	int step;
	
	KnightPos() : row(0), col(0), step(0) {}
	
	bool operator>(const KnightPos& p) const
	{
		int myDist = abs(float(row - g_desRow)) + abs(float(col - g_desCol));
		int otherDist = abs(float(p.row - g_desRow)) + abs(float(p.col - g_desCol));
		
		if (myDist != otherDist)
		{
			return myDist > otherDist; 
		}
		else
		{
			return step > p.step;
		}
	}
};

priority_queue< KnightPos, vector<KnightPos>, greater<KnightPos> > g_queue;
int g_board[8][8];

int dirRow[] = { 2, 1, -1, -2, -2, -1,  1,  2};
int dirCol[] = { 1, 2,  2,  1, -1, -2, -2, -1};



int calc()
{
	int minStep = 100000;
	while (!g_queue.empty())
	{
		KnightPos pos = g_queue.top();
		g_queue.pop();
		if (pos.step >= minStep) { continue; }
		
		for (int i = 0; i < 8; ++i)
		{
			KnightPos posNext;
			posNext.row = pos.row + dirRow[i];
			posNext.col = pos.col + dirCol[i];
			posNext.step = pos.step + 1;
			
			
			if (posNext.row < 0 || posNext.col < 0 || posNext.row > 7 || posNext.col > 7) { continue; }
			
			if (posNext.step > minStep)
			{
				break;
			}
			
			if (posNext.row == g_desRow && posNext.col == g_desCol)
			{
				minStep = posNext.step < minStep ? posNext.step : minStep;
				break;
			}
			
			if (g_board[posNext.row][posNext.col] == -1 || g_board[posNext.row][posNext.col] > posNext.step)
			{
				g_board[posNext.row][posNext.col] = posNext.step;
			}
			else
			{
				continue;
			}
			
			
			g_queue.push(posNext);
		}
	}
	return minStep;
}

int main()
{
#ifdef READ_FILE
	ifstream in("1091.input");
	if (!in) { in.open("../1091.input"); }
#else
	#define in cin
#endif

	char begCol, begRow, endCol, endRow;
	int moves = 0;
	while (in >> begCol >> begRow >> endCol >> endRow)
	{
		if (begCol == endCol && begRow == endRow)
		{
			moves = 0;
		}
		else
		{
			while (!g_queue.empty()) { g_queue.pop(); }
			
			memset(g_board, -1, sizeof(g_board));
			
			g_desCol = endCol - 'a';
			g_desRow = endRow - '1';
			
			KnightPos pos;
			pos.col = begCol - 'a';
			pos.row = begRow - '1';
			
			g_queue.push(pos);
			g_board[pos.row][pos.col] = 0;
			
			moves = calc();
		}
		
		cout << "To get from " << begCol << begRow << " to " << endCol << endRow << " takes " << moves << " knight moves." << endl;
	}
	return 0;
}